<template>
  <div class="mod-hotSearcch">
    <div class="right bgwhite">
   
      <avue-crud ref="crud" :data="dataSolvePlanList" :table-loading="dataListLoading" :option="tableSolvePlanOption"
        :page="page" @search-change="searchChange" @on-load="getDataList" @refresh-change="refreshChange">
        <template slot="menuLeft">
        

        </template>
      </avue-crud>
    </div>

  </div>
</template>

<script>
import { tableOption } from '@/crud/shop/hotSearch';
import { tableSolvePlanOption } from '@/crud/manage/solve-plan'

export default {
  components: {
  
  },
  data() {
    return {
      dataForm: {

      },
      tableSolvePlanOption: tableSolvePlanOption,
      dataSolvePlanList: [],
      dataList: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false,
      tableOption: tableOption
    }
  },
 
  methods: {
  
    // 获取数据列表
    getDataList(page, params, done) {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/crm/month/plan/page'),
        method: 'get',
        params: this.$http.adornParams(Object.assign({
          current: page.currentPage,
          size: page.pageSize
        }, params))
      }).then(({ data }) => {
        this.page.total = data.obj.total;
        this.dataSolvePlanList = data.obj.records
        this.dataListLoading = false
        if (done) {
          done()
        }
      })
    },
    // 多选回调
    selectionChange(list) {
      this.dataListSelections = list
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id)
      })
    },
    // 点击查询
    searchChange(params, done) {
      this.getDataList(this.page, params, done)
    },
    // 删除
    deleteHandle(row, index) {
      var ids = row.hotSearchId ? [row.hotSearchId] : this.dataListSelections.map(item => {
        return item.hotSearchId
      })
      this.$confirm(`确定进行[${row.hotSearchId ? '删除' : '批量删除'}]操作?`, '友情提醒', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl('/admin/hotSearch'),
          method: 'delete',
          data: this.$http.adornData(ids, false)
        }).then(({ data }) => {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.getDataList()
            }
          })
        })
      }).catch(() => { })
    },
    refreshChange() {
      this.getDataList(this.page)
    }
  }
}
</script>
